﻿using System;

namespace EQMCHelpers
{
}

namespace EQMCSharpPayoffs
{
    public class EQMCBase
    {
        public void init(int trials_, int unds_, int obs_) 
        {
            //trials = trials_;
            nUnds = unds_;
            nObs = obs_;
            nSch2s = 13;
            path = new double[trials_, nUnds, nObs+1];
            Random r = new Random();
            for (int i = 0; i < trials_; ++i)
                for (int u = 0; u < unds_; ++u)
                    for (int t = 0; t <= obs_; ++t)
                        path[i,u,t] = 100 + Math.Sqrt(t) * (r.NextDouble() - 0.5);

        }

        public int getInt(string name, int def)
        {
            if (name == "nReturns")
                return 50;
            return def;
        }
        public double getDouble(string name, double def)
        {
            return def;
        }
        public string getString(string name, string def)
        {
            return def;
        }
        public double yearFraction(int t1, int t2, string dayCountBasis)
        {
            return 1.0;
        }
        public bool isEvent(int t, string type)
        {
            if(type=="sch1")
                return t==51;
            else if(type=="sch2")
            {
                switch(t)
                {
                    case 1193:
                    case 1213:
                    case 1233:
                    case 1248:
                    case 1266:
                    case 1286:
                    case 1307:
                    case 1323:
                    case 1344:
                    case 1365:
                    case 1385:
                    case 1406:
                    case 1424:
                        return true;
                }
            }
            return false;
        }

        public string SCH1 { get { return "sch1"; } }
        public string SCH2 { get { return "sch2";  } }
        public int nObs;
        public int nUnds;
        public int nSch2s;
        public double weight(int und) { return 0.2; }
        public double strikeFactor = 1.0;

        double[,,] path;
        public double NS(int trial, int und, int t) { return path[trial, und, t];  }

        public enum DerType { PUT, CALL, FWD };
        public DerType PUT { get { return DerType.PUT; } }
        public DerType CALL { get { return DerType.CALL; } }
        public DerType FWD { get { return DerType.FWD; } }
        public DerType derivativeType;

        public double finalPayoff = 0.0;
    }
}
